var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/functionalComponent/toolbar/index.tsx
var toolbar_exports = {};
__export(toolbar_exports, {
  ButtonEnum: () => import_enums.ButtonEnum,
  ToolBar: () => ToolBar,
  candidateButtons: () => import_candidate.candidateButtons
});
module.exports = __toCommonJS(toolbar_exports);
var import_icons = require("@ant-design/icons");
var import_antd = require("antd");
var import_react = __toESM(require("react"));
var import_util = require("../../util");
var import_Button = require("../antd/Button");
var import_bridge = require("./bridge");
var import_enums = require("./enums");
var import_registerButton = require("./registerButton");
var import_index = require("./index.less");
var import_candidate = require("./candidate");
import_util.iup.registerExternal({ getRegisterButton: import_registerButton.getToolBarButton });
var menuButtonProps = { type: "text", size: "small" };
var getSize = (size) => size ? size === "simple" ? "middle" : size : "middle";
function SpaceFlex() {
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "space-flex", style: { flex: 1 } });
}
function UserComponent({ toolbar, children, uid, type }) {
  const { hidden, disabled } = toolbar.calcButtonProps(children);
  return /* @__PURE__ */ import_react.default.createElement("div", { "data-cid": uid, className: "user-component", style: { marginRight: `${type === "link" ? 8 : 0}px` } }, import_react.default.isValidElement(children) ? import_react.default.cloneElement(children, { disabled, hidden }) : children);
}
function createIcon(icon, props = {}) {
  if (icon === void 0) {
    icon = "ApiOutlined";
  }
  if (!icon)
    return null;
  if (import_util.iup.isString(icon)) {
    return import_react.default.createElement(import_util.BaseIcon[icon] || import_util.BaseIcon["ApiOutlined"], props);
  } else {
    return import_react.default.cloneElement(icon, { ...props, style: { ...icon.props.style, ...props.style } });
  }
}
var dropStyle = {
  padding: "5px 12px",
  height: "auto",
  minHeight: 24,
  minWidth: 90,
  width: "100%",
  textAlign: "left"
};
var getMenuItems = (toolbar, menuArray) => {
  const items = [];
  menuArray.forEach((menu, index) => {
    const button = toolbar.format(menu.button || menu);
    if (button.type === "divider") {
      items.push({
        key: button.id,
        label: /* @__PURE__ */ import_react.default.createElement(import_antd.Divider, { type: "horizontal", style: { margin: "5px 0" } })
      });
      return;
    }
    if (button.type === "userComponent" || import_react.default.isValidElement(button)) {
      const tmp = button.text || button;
      const { hidden: hidden2, disabled: disabled2 } = toolbar.calcButtonProps(tmp);
      items.push({
        key: button.id || `user_${index}`,
        label: /* @__PURE__ */ import_react.default.createElement("div", { onClick: (e) => import_util.iup.stopPropagation(e), style: { padding: "5px 12px" } }, import_react.default.isValidElement(tmp) ? import_react.default.cloneElement(tmp, { disabled: disabled2, hidden: hidden2 }) : tmp)
      });
      return;
    }
    const { hidden, text, disabled, size } = toolbar.calcButtonProps(button);
    if (hidden) {
      return;
    }
    if (button.children) {
      items.push({
        key: button.id,
        disabled,
        label: text,
        popupClassName: import_util.iup.classNames("iup-toolbar-submenu", size),
        children: getMenuItems(toolbar, button.children)
      });
    } else {
      items.push({
        key: button.id,
        disabled,
        label: /* @__PURE__ */ import_react.default.createElement(ToolBarItem, { style: dropStyle, key: button.id, button, toolbar, isMenuItem: true })
      });
    }
  });
  return items;
};
function FoldMenu({ toolbar }) {
  var _a;
  const elRef = (0, import_react.useRef)();
  const initDropdown = (0, import_util.useRefCallback)(() => {
    var _a2;
    const tbEl = elRef.current.parentElement;
    if (!tbEl) {
      return;
    }
    if (!toolbar.btnWidths) {
      toolbar.btnWidths = {};
    }
    const tbOffsetWidth = tbEl.offsetWidth;
    const tbScrollWidth = tbEl.scrollWidth;
    const dropdown = [];
    if (tbOffsetWidth < tbScrollWidth) {
      let tmpWidth = (((_a2 = tbEl.querySelector(".iup-btn-more")) == null ? void 0 : _a2.offsetWidth) || (["text", "link"].includes(toolbar.props.type) ? 48 : 82)) + (parseFloat(import_util.iup.getStyle(tbEl, "paddingLeft")) || 0) + (parseFloat(import_util.iup.getStyle(tbEl, "paddingRight")) || 0);
      tbEl.childNodes.forEach((child) => {
        var _a3, _b;
        const itemId = ((_a3 = child.getAttribute) == null ? void 0 : _a3.call(child, "id")) || ((_b = child.getAttribute) == null ? void 0 : _b.call(child, "data-cid"));
        let childOffsetWidth = toolbar.btnWidths[itemId];
        if (import_util.iup.isNullOrEmpty(childOffsetWidth)) {
          childOffsetWidth = child.offsetWidth + (parseFloat(import_util.iup.getStyle(child, "marginLeft")) || 0) + (parseFloat(import_util.iup.getStyle(child, "marginRight")) || 0);
          itemId && (toolbar.btnWidths[itemId] = childOffsetWidth);
        }
        tmpWidth += childOffsetWidth;
        if (tmpWidth > tbOffsetWidth && itemId) {
          dropdown.push({
            button: function() {
              var _a4;
              if (itemId.indexOf("_divider_") === 0) {
                return { type: "divider", id: itemId };
              }
              if (itemId.indexOf("_user_component_") === 0) {
                return { type: "userComponent", id: itemId, text: (_a4 = toolbar.userComponents) == null ? void 0 : _a4[itemId] };
              }
              return toolbar.findItem(itemId);
            }(),
            itemId,
            width: childOffsetWidth
          });
        }
      });
    }
    if (toolbar.state.dropdown.length !== dropdown.length) {
      toolbar.setState((prev) => ({ ...prev, dropdown }));
    }
  });
  (0, import_react.useLayoutEffect)(() => {
    toolbar.btnWidths = {};
    initDropdown();
  }, [toolbar.state.resize]);
  const getParentEl = (0, import_util.useRefCallback)(() => elRef.current.parentElement);
  (0, import_util.useResize)(() => {
    toolbar.setState((prev) => ({ ...prev, dropdown: [], resize: {} }));
  }, getParentEl);
  (0, import_util.useUpdateEffect)(() => {
    toolbar.setState((prev) => ({ ...prev, dropdown: [], resize: {} }));
  }, [toolbar.dev.size, toolbar.dev.type, toolbar.dev.buttons]);
  const btnProps = { ...menuButtonProps, size: getSize(toolbar.dev.size), type: toolbar.dev.type || "default" };
  if (btnProps.size === "small" && ["link", "text"].includes(btnProps.type) && !((_a = btnProps.style) == null ? void 0 : _a.padding)) {
    btnProps.style = { ...btnProps.style, padding: 0 };
  }
  const showMore = !!toolbar.state.dropdown.length;
  return /* @__PURE__ */ import_react.default.createElement(
    "span",
    {
      ref: elRef,
      style: { display: showMore ? "flex" : "none" },
      children: showMore && (import_util.iup.isFunction(toolbar.dev.moreIcon) ? toolbar.dev.moreIcon(toolbar.state.dropdown.map(({ button }, idx) => toolbar.format(button, idx))) : /* @__PURE__ */ import_react.default.createElement(
        import_antd.Dropdown,
        {
          menu: {
            items: getMenuItems(toolbar, toolbar.state.dropdown),
            className: import_util.iup.classNames("iup-toolbar-menu", getSize(toolbar.dev.size))
          },
          onOpenChange: toolbar.onOpenChange({})
        },
        /* @__PURE__ */ import_react.default.createElement(import_Button.Button, { ...btnProps, className: "iup-btn-more" }, "更多", toolbar.dev.moreIcon || createIcon("DownOutlined", {
          style: toolbar.dev.iconColor ? { color: toolbar.dev.iconColor, marginLeft: 5 } : { marginLeft: 5 }
        }))
      ))
    }
  );
}
function TooltipButton({ title, buttonProps, outRef, badgeText }) {
  const render = () => {
    if (badgeText) {
      return /* @__PURE__ */ import_react.default.createElement(import_antd.Badge, { count: badgeText, size: "small", styles: { root: { color: "inherit" } }, offset: [-10, 2] }, /* @__PURE__ */ import_react.default.createElement(import_Button.Button, { ...buttonProps, ref: outRef }));
    }
    return /* @__PURE__ */ import_react.default.createElement(import_Button.Button, { ...buttonProps, ref: outRef });
  };
  return title ? /* @__PURE__ */ import_react.default.createElement(import_antd.Tooltip, { title }, render()) : render();
}
var ToolBarItem = class extends import_util.IUPComponent {
  constructor(props) {
    super(props);
    this.state = {
      defaultBadge: void 0
    };
  }
  async componentDidMount() {
    var _a;
    (_a = this.props.toolbar) == null ? void 0 : _a.addItemMap(this);
  }
  componentWillUnmount() {
    var _a;
    (_a = this.props.toolbar) == null ? void 0 : _a.deleteItemMap(this);
  }
  isSimpleButton() {
    const { toolbar, button, isMenuItem = false } = this.props;
    return !isMenuItem && (toolbar.dev.size === "simple" || button.simple);
  }
  getApi() {
    var _a;
    return {
      ...(_a = this.outRef.current) == null ? void 0 : _a.getApi(),
      setState: (...args) => this.setState(args[0], args[1]),
      setDisabled: (disabled = true) => this.setDisabled(disabled),
      setHidden: (hidden = true) => this.setHidden(hidden),
      isSimpleButton: () => this.isSimpleButton(),
      isVisible: () => {
        const { button, toolbar } = this.props;
        const { hidden } = toolbar.calcButtonProps(button);
        return !hidden;
      }
    };
  }
  setStateProps(stateKey, stateValue) {
    const { toolbar, button } = this.props;
    toolbar.setItemProps(button.originid, { [stateKey]: stateValue });
  }
  setDisabled(disabled = true) {
    this.setStateProps("disabled", disabled);
  }
  setHidden(hidden = true) {
    this.setStateProps("hidden", hidden);
  }
  render() {
    const { button, toolbar, isMenuItem, style } = this.props;
    const { originid, children, onClick, getClickParams } = button;
    const { iconColor, badge } = toolbar.dev;
    const { defaultBadge } = this.state;
    const { icon, text, hidden, disabled, type: buttonType, size, buttonStyle } = toolbar.calcButtonProps(button);
    if (hidden) {
      return null;
    }
    const type = isMenuItem ? "text" : buttonType;
    const btnProps = {
      ...menuButtonProps,
      getClickParams,
      type,
      className: "iup-toolbar-button",
      style: { margin: `${["text", "link"].includes(type) ? 0 : "0 4px"}`, ...style, ...buttonStyle },
      originid,
      id: button.id,
      containerId: "",
      disabled,
      size
    };
    if (size === "small" && ["link"].includes(type) && !btnProps.style.padding) {
      btnProps.style.padding = 0;
      btnProps.style.marginRight = 8;
    }
    let badgeText = (import_util.iup.isFunction(badge) ? badge(originid) : badge == null ? void 0 : badge[originid]) ?? defaultBadge;
    if (children) {
      const innerText = [
        text,
        /* @__PURE__ */ import_react.default.createElement(
          import_icons.DownOutlined,
          {
            key: "DownOutlined",
            className: "iup-btn-icon",
            style: {
              marginLeft: 5,
              ...iconColor ? { color: iconColor } : {}
            }
          }
        )
      ];
      return /* @__PURE__ */ import_react.default.createElement(
        import_antd.Dropdown,
        {
          menu: { items: getMenuItems(toolbar, children), className: import_util.iup.classNames("iup-toolbar-menu", size) },
          disabled,
          onOpenChange: toolbar.onOpenChange(this),
          children: this.isSimpleButton() ? /* @__PURE__ */ import_react.default.createElement(TooltipButton, { title: innerText, badgeText, buttonProps: btnProps, outRef: this.outRef }) : /* @__PURE__ */ import_react.default.createElement(import_Button.Button, { ...btnProps, children: innerText })
        }
      );
    } else if (import_util.iup.isString(text) || icon) {
      btnProps.icon = createIcon(icon, {
        className: "iup-btn-icon",
        style: {
          ...iconColor ? { color: iconColor } : {}
        }
      });
    }
    if (this.isSimpleButton()) {
      return /* @__PURE__ */ import_react.default.createElement(
        TooltipButton,
        {
          title: text,
          badgeText,
          outRef: this.outRef,
          buttonProps: { ...btnProps, onClick, style: { ...btnProps.style, minWidth: 30 } }
        }
      );
    }
    if (import_util.iup.isReactElement(text)) {
      return /* @__PURE__ */ import_react.default.createElement("div", { style: { margin: 0, ...style, ...buttonStyle } }, import_react.default.cloneElement(text, { disabled }));
    }
    badgeText = badgeText ? /* @__PURE__ */ import_react.default.createElement(
      import_antd.Badge,
      {
        count: badgeText,
        size: "small",
        styles: { root: { color: "inherit" } },
        offset: [isMenuItem ? 5 : size === "small" ? 3 : 5, size === "small" ? -2 : -6]
      },
      text
    ) : text;
    return /* @__PURE__ */ import_react.default.createElement(import_Button.Button, { ref: this.outRef, ...btnProps, onClick, children: badgeText });
  }
};
var ToolBar = (0, import_util.compHoc)(
  class extends import_util.IUPComponent {
    constructor(props) {
      super(props);
      this._itemMap = /* @__PURE__ */ new Map();
      this.randomKey = "";
      this.mountButtons = [];
      this.divRef = import_react.default.createRef();
      this.userComponents = {};
      this.dev = {};
      this.direction = { left: "left", right: "left" };
      //  justifyContent right 滚动条宽度有问题
      this.getAffixTarget = () => {
        var _a;
        return import_util.iup.closest(
          (_a = this.divRef.current) == null ? void 0 : _a.parentNode,
          (el) => el.scrollWidth > el.offsetWidth || el.scrollHeight > el.offsetHeight
        ) || window;
      };
      this.randomKey = props.id || Math.random().toString(36).slice(2);
      this.state = {
        affixed: false,
        dropdown: [],
        rights: { disableBtn: [], hideBtn: [] }
      };
    }
    static getDerivedStateFromProps(nextProps, prevState) {
      const newState = import_util.IUPComponent.propsToState(nextProps, prevState, ["buttons"]);
      if (newState == null ? void 0 : newState.hasOwnProperty("buttons")) {
        return { ...newState, dropdown: [] };
      }
      return newState;
    }
    async componentDidMount() {
      var _a, _b, _c, _d;
      this.mountButtons = [...this.props.buttons];
      if (this.props.rightName) {
        (_b = (_a = import_util.iup.getPageInstance()) == null ? void 0 : _a.subscribeButtonRights) == null ? void 0 : _b.call(_a, (rights) => {
          this.setState((prev) => ({ ...prev, rights }));
        }, this.props.rightName);
      }
      (_d = (_c = import_util.iup.getPageInstance()) == null ? void 0 : _c.subscribeButtonRights) == null ? void 0 : _d.call(_c, ({ replace, ...rights }) => {
        this.setState((prev) => {
          if (replace) {
            return { ...prev, rights };
          }
          const { disableBtn = [], hideBtn = [] } = prev.rights;
          const { disableBtn: nd = [], hideBtn: nh = [] } = rights;
          return {
            ...prev,
            rights: {
              disableBtn: [.../* @__PURE__ */ new Set([...disableBtn, ...nd])],
              hideBtn: [.../* @__PURE__ */ new Set([...hideBtn, ...nh])]
            }
          };
        });
      }, "$global$");
    }
    componentWillUnmount() {
      this.props.buttons.splice(0, this.props.buttons.length, ...this.mountButtons);
    }
    /**
     * 计算按钮属性
     * @param button
     */
    calcButtonProps(btn) {
      const button = { ...btn, ...btn.props };
      const {
        hidden,
        text,
        disabled,
        icon,
        type = this.dev.type || "default",
        size = this.dev.size || "middle",
        style = {}
      } = button;
      const rightKey = button.rightKey || button.originid || button.key;
      const { disabledKeys = [], hiddenKeys = [], showIcon = true } = this.dev;
      const { rights } = this.state;
      return {
        hidden: hidden || hiddenKeys.includes(button.originid || rightKey) || rights.hideBtn.includes(rightKey),
        text,
        icon: showIcon ? icon : null,
        type,
        size: getSize(size),
        buttonStyle: style,
        disabled: disabled || disabledKeys.includes(button.originid || rightKey) || rights.disableBtn.includes(rightKey)
      };
    }
    async refreshRight(params) {
      var _a, _b;
      const { rightName } = this.props;
      if (rightName) {
        return (_b = (_a = import_util.iup.getPageInstance()) == null ? void 0 : _a.refreshButtonRights) == null ? void 0 : _b.call(_a, { ...params, rightName });
      }
    }
    /**
     * 原始button数据转换成标准的button格式
     * @param button 候选key或者自定义button
     */
    format(button, idx) {
      var _a, _b, _c;
      let tmpButton = null;
      if (import_util.iup.isReactElement(button)) {
        return button;
      }
      const isObject = import_util.iup.isObject(button);
      const itemId = isObject ? button["id"] : button;
      const find = (0, import_registerButton.getToolBarButton)(itemId);
      if (find) {
        tmpButton = isObject ? { ...find, ...button } : { ...find, id: itemId };
      } else {
        tmpButton = isObject ? { ...button } : null;
      }
      if (tmpButton && tmpButton.id) {
        const btnId = tmpButton.originId || tmpButton.id;
        const langKey = tmpButton.langKey || btnId;
        const onClickCallback = tmpButton.onClick;
        tmpButton.text = ((_a = import_util.iup.getPageLang()) == null ? void 0 : _a[langKey]) || ((_c = (_b = import_util.iup.getUser()) == null ? void 0 : _b.toolbarLang) == null ? void 0 : _c[langKey]) || tmpButton.text;
        const getData = tmpButton.getData || this.props.getData;
        const params = {
          id: btnId,
          key: btnId,
          containerId: this.props.containerId || this.getId(),
          text: tmpButton.text,
          toolbar: this,
          getData,
          origin: {
            icon: tmpButton.icon,
            text: tmpButton.text,
            hidden: !!tmpButton.hidden
          }
        };
        tmpButton.onClick = async () => {
          return await (0, import_bridge.handleClick)({
            ...params,
            onClick: onClickCallback || this.props.onClick,
            button: tmpButton
          });
        };
        if (onClickCallback) {
          tmpButton.getClickParams = () => {
            return { ...params };
          };
        }
        tmpButton.id = idx === void 0 ? btnId : this.randomKey + "$" + btnId + idx;
        tmpButton.originid = btnId;
        if (!tmpButton.type && this.props.type) {
          tmpButton.type = this.props.type;
        }
      }
      return tmpButton;
    }
    /**
     * 查找原始props.button对象
     * @param originId 定义的id
     */
    findOriginItem(originId) {
      return this.dev.buttons.find((btn) => btn.id === originId || btn === originId);
    }
    findItem(itemId) {
      const item = this.dev.buttons.find((btn, idx) => {
        const id = this.randomKey + "$" + (import_util.iup.isString(btn) ? btn : btn.id) + idx;
        return id === itemId;
      });
      return item;
    }
    /**
     * 保存button实例的映射，方便查找button
     * @param item button实例
     */
    addItemMap(item) {
      this._itemMap.set(item.props.button.originid, item);
    }
    /**
     * 删除button实例的映射，button销毁时调用
     * @param item button实例
     */
    deleteItemMap(item) {
      this._itemMap.delete(item.props.button.originid);
    }
    /**
     * 获取button实例
     * @param itemId button的id
     */
    getItem(itemId) {
      var _a;
      return (_a = this._itemMap.get(itemId)) == null ? void 0 : _a.getApi();
    }
    /**
     * 获取toolbar的按钮权限数据（服务端返回）
     */
    getRights() {
      return this.state.rights;
    }
    /**
     * 动态设置button的属性
     * @param itemId  button的id
     * @param props {icon, text, hidden}
     */
    setItemProps(itemId, props) {
      import_util.iup.fastDp.toolbar.updateItems({ id: this.getId(), items: [{ id: itemId, ...props }] });
    }
    /**
     * 设置button可见
     * @param itemId button的id
     */
    showButton(itemId) {
      this.setItemProps(itemId, { hidden: false });
    }
    /**
     * 设置button不可见
     * @param itemId button的id
     */
    hideButton(itemId) {
      this.setItemProps(itemId, { hidden: true });
    }
    setHidden(itemId, hidden = true) {
      this.setItemProps(itemId, { hidden });
    }
    setReadOnly(itemId, disabled = true) {
      this.setItemProps(itemId, { disabled });
    }
    /**
     * 获取当前的buttons
     */
    getButtons() {
      return this.dev.buttons;
    }
    /**
     * 动态添加button
     * @param button
     * @param index
     */
    insert(button, index = -1) {
      if (!import_util.iup.isArray(button)) {
        button = [button];
      }
      import_util.iup.fastDp.toolbar.addItems({ id: this.getId(), items: button, insertIndex: index });
    }
    /**
     * 删除button
     * @param ids buttonItem的id集合
     */
    delete(ids) {
      if (!import_util.iup.isArray(ids)) {
        ids = [ids];
      }
      import_util.iup.fastDp.toolbar.deleteItems({ id: this.getId(), items: ids });
    }
    /**
     * 设置buttons
     * @param handler 处理事件
     */
    setButtons(handler) {
      import_util.iup.fastDp.toolbar.setItems({ id: this.getId(), items: handler });
    }
    subscribe(fn, type, buttonId) {
      if (buttonId && buttonId.length > 0) {
        const arr = import_util.iup.isArray(buttonId) ? buttonId : [buttonId];
        return this.innerSubscribe(fn, type, ({ args }) => arr.includes(args[0].id));
      } else {
        return this.innerSubscribe(fn, type);
      }
    }
    onOpenChange(btn) {
      return (open) => {
        var _a, _b;
        (_b = (_a = this.dev).onOpenChange) == null ? void 0 : _b.call(_a, open, btn);
      };
    }
    render() {
      return /* @__PURE__ */ import_react.default.createElement(InnerToolbar, { ins: this });
    }
  },
  "ToolBar"
);
function InnerToolbar({ ins }) {
  const { dropdown, buttons: items, affixed } = ins.state;
  const [props, buttons] = (0, import_util.useDevState)({ type: "toolbar", id: ins.getId(), props: ins.props, items, itemKey: "id" });
  const { style, affix = false, direction = "left", type = "button", className = "", stopPropagation = true } = props;
  ins.dev = { ...props, buttons };
  const tb = /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      id: ins.getId(),
      className: `iup-toolbar ${type} ${className}`,
      ref: ins.divRef,
      onClick: (e) => stopPropagation ? import_util.iup.stopPropagation(e) : void 0,
      style: {
        display: "flex",
        width: "100%",
        maxWidth: "100%",
        minHeight: 24,
        padding: "var(--inner-padding, 8px) 4px",
        alignItems: "center",
        justifyContent: ins.direction[direction] || direction,
        boxShadow: affix && affixed ? "0 10px 8px -8px #e0e0e0" : "none",
        overflow: "hidden",
        ...style
      }
    },
    direction === "right" && /* @__PURE__ */ import_react.default.createElement(SpaceFlex, { key: "right_1" }),
    buttons.map((btn, index) => {
      const tmp = ins.format(btn, index);
      const itemId = (tmp == null ? void 0 : tmp.id) ?? (tmp == null ? void 0 : tmp.originid) ?? "";
      if (index === 0 && tmp && !import_util.iup.isReactElement(tmp) && !tmp.type) {
        tmp.type = "primary";
      }
      if (!tmp || dropdown.some(
        (d) => {
          var _a;
          return d.itemId === itemId || [`_divider_${index}`, `_user_component_${index}`].includes((_a = d.button) == null ? void 0 : _a.id);
        }
      )) {
        return null;
      }
      if (import_util.iup.isReactElement(tmp)) {
        const uid = `_user_component_${index}`;
        ins.userComponents[uid] = tmp;
        return /* @__PURE__ */ import_react.default.createElement(UserComponent, { uid, key: uid, toolbar: ins, children: tmp, type: props.type });
      }
      if (tmp.type === "flex") {
        return /* @__PURE__ */ import_react.default.createElement(SpaceFlex, { key: tmp.id || index });
      }
      if (tmp.type === "divider") {
        return /* @__PURE__ */ import_react.default.createElement(import_antd.Divider, { type: "vertical", key: `_divider_${index}`, "data-cid": `_divider_${index}` });
      }
      return /* @__PURE__ */ import_react.default.createElement(ToolBarItem, { key: tmp.id || index, button: tmp, toolbar: ins });
    }),
    /* @__PURE__ */ import_react.default.createElement(FoldMenu, { toolbar: ins })
  );
  if (affix) {
    const affixConfig = import_util.iup.isObject(affix) ? affix : {};
    return /* @__PURE__ */ import_react.default.createElement(import_antd.Affix, { target: ins.getAffixTarget, ...affixConfig, onChange: (affixed2) => ins.setState({ affixed: affixed2 }) }, tb);
  }
  return tb;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ButtonEnum,
  ToolBar,
  candidateButtons
});
